<!DOCTYPE HTML>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title> 卸载事件 </title>
    <script type="text/javascript">

    function onunload_message() {
        alert("您确定离开该网页吗？");
    }
    window.onunload = onunload_message;
    </script>
</head>

<body>
    欢迎学习JavaScript。
</body>

</html>